﻿// =====================================================================
//
//  This file is part of the Microsoft Dynamics CRM SDK code samples.
//
//  Copyright (C) Microsoft Corporation.  All rights reserved.
//
//  This source code is intended only as a supplement to Microsoft
//  Development Tools and/or on-line documentation.  See these other
//  materials for detailed information regarding Microsoft code samples.
//
//  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//
// =====================================================================
using System.Runtime.Serialization;
using Microsoft.Xrm.Sdk.Temporary;

namespace Microsoft.Xrm.Sdk
{
	[DataContract(Name = "Label", Namespace = XmlNamespaces.V5.Contracts)]
	public sealed class Label : IExtensibleDataObject
	{
		private LocalizedLabelCollection _locLabels;
		private LocalizedLabel _userLocLabel;

		public Label()
		{
		}

		public Label(string label, int languageCode)
		{
			_locLabels = new LocalizedLabelCollection();
			_locLabels.Add(new LocalizedLabel(label, languageCode));
		}

		public Label(LocalizedLabel userLocalizedLabel, LocalizedLabel[] labels)
		{
			_userLocLabel = userLocalizedLabel;
			if (labels != null)
				_locLabels = new LocalizedLabelCollection(labels);
		}

		[DataMember]
		public LocalizedLabelCollection LocalizedLabels
		{
			get
			{
				if (null == this._locLabels)
				{
					this._locLabels = new LocalizedLabelCollection();
				}
				return this._locLabels;
			}
			internal set { this._locLabels = value; }
		}

		[DataMember]
		public LocalizedLabel UserLocalizedLabel
		{
			get { return this._userLocLabel; }
			set { this._userLocLabel = value; }
		}
		#region IExtensibleDataObject Implementation
		private ExtensionDataObject ExtensionDataObject;
		public ExtensionDataObject ExtensionData
		{
			get
			{
				return ExtensionDataObject;
			}
			set
			{
				ExtensionDataObject = value;
			}
		}
		#endregion IExtensibleDataObject Implementation
	}
}
